﻿using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using DiagnosticCenter.View;

namespace DiagnosticCenter.ViewModel
{
    public partial class uiAnswerRelation
    {
        public ObservableCollection<AnswerInfo> ItemsList { get; set; }

        public uiAnswerRelation()
        {
            InitializeComponent();
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {

            var button = (Button)sender;
            var location = listRelationRight.SelectedIndex;
            var rememberMe = ItemsList[location];

            if (button.Name == "buttonUp")
            {
                if (location > 0)
                {
                    ItemsList.RemoveAt(location);
                    ItemsList.Insert(location - 1, rememberMe);
                    listRelationRight.SelectedIndex = location - 1;
                }
            }
            else if (button.Name == "buttonDown")
            {
                if (location < listRelationRight.Items.Count - 1)
                {
                    ItemsList.RemoveAt(location);
                    ItemsList.Insert(location + 1, rememberMe);
                    listRelationRight.SelectedIndex = location + 1;
                }
            }
        }
    }
}
